local xuyi = fk.CreateSkill{
  name = "rfenghou_3d17j__xuyinull",
}

Fk:addQmlMark{
  name = "rfenghou_3d17j_numberlist",
  how_to_show = function(name, value, player)
    if type(value) ~= "table" then
      return " "
    end
    if #value == 1 then
      return tostring(value[1])
    elseif #value < 5 then
      return table.concat(value, "/")
    else
      return " "
    end
  end,
  qml_path = "packages/aaa_Romantic/qml/NumberListBox"
}

xuyi:addEffect("viewas", {
  pattern = "nullification",
  anim_type = "support",
  prompt = "#rfenghou_3d17j__xuyinull",
  mute_card = false,
  card_filter = Util.FalseFunc,
  view_as = function(self, player, cards)
    local card = Fk:cloneCard("nullification")
    card.skillName = xuyi.name
    return card
  end,
  before_use = function(self, player, use)
    local t = player:getTableMark("@[rfenghou_3d17j_numberlist]rfenghou_3d17j__xuyinull")
    table.insert(t, player:getHandcardNum())
    table.sort(t)
    player.room:setPlayerMark(player, "@[rfenghou_3d17j_numberlist]rfenghou_3d17j__xuyinull", t)
    player.room:addPlayerMark(player, MarkEnum.AddMaxCards, 1)
    use.card:addSubcards(player:getCardIds("h"))
  end,
  after_use = function(self, player, use)
    local room = player.room
    local maxhand = player:getMaxCards()
    local maxs = table.filter(room:getAllPlayers(false), function(target)
      return target:getMaxCards() >= maxhand
    end)
    if #maxs == 0 then return end
    local target = room:askToChoosePlayers(player, {
      targets = maxs,
      min_num = 1,
      max_num = 1,
      skill_name = xuyi.name,
      prompt = "#rfenghou_3d17j__xuyinull-ask"
    })[1]
    if target then
      target:drawCards(2, xuyi.name)
    end
  end,
  enabled_at_response = function(self, player, response)
    return not response and not player:isKongcheng() and not table.contains(player:getTableMark("@[rfenghou_3d17j_numberlist]rfenghou_3d17j__xuyinull"), player:getHandcardNum())
  end,
  enabled_at_nullification = function(self, player, data)
    return not player:isKongcheng() and not table.contains(player:getTableMark("@[rfenghou_3d17j_numberlist]rfenghou_3d17j__xuyinull"), player:getHandcardNum())
  end
})

Fk:loadTranslationTable{
  ["rfenghou_3d17j__xuyinull"] = "序仪",
  [":rfenghou_3d17j__xuyinull"] = "每手牌数限一次，你可以将所有手牌当【无懈可击】使用并令手牌上限+1，然后你可以令一名手牌上限不小于你的角色摸两张牌。",

  ["#rfenghou_3d17j__xuyinull"] = "序仪：将所有手牌当【无懈可击】使用并令手牌上限+1，然后你可以令一名手牌上限不小于你的角色摸两张牌",

  ["#rfenghou_3d17j__xuyinull-ask"] = "序仪：你可以令一名手牌上限不小于你的角色摸两张牌",

  ["@[rfenghou_3d17j_numberlist]rfenghou_3d17j__xuyinull"] = "序仪",
}

return xuyi
